<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的收藏夹</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/layer.css" />
    <link rel="stylesheet" type="text/css" href="../css/mdw.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/swiper.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/layer.js"></script>
    <script type="text/javascript" src="../script/mdw.js"></script>
    <script type="text/javascript" src="../script/jumpPage.js"></script>
</head>
<body class="bg-eee">
    <header class="header">
        <div class="backPrevPage on" onclick="historyBack()"></div>
        <div class="pageTitle">我的收藏夹</div>
        
    </header>
    <section class="favoritePage HTML_BOX">
        <div class="bg-eee" style="border-bottom:.2rem solid #EEE ; "></div>
        <ul class="orderClass displayFlex bg-fff">
            <li class="on f_c">商品<i></i></li>
            <li class="f_c">商家<i></i></li>
            <li class="f_c">社区<i></i></li>
        </ul>
        <ul class="favoritePageList bg-fff">

            <!-- <li id="ware_1" class="wareInfo">
                    <div class="wareImage">
                        <img src="../image/testsp.png" />
                    </div>
                    <div class="wareData">
                        <div class="wareName">广西车厘子</div>
                        <div class="wareGuiGe">2kg</div>
                        <div class="warePrice">
                            <div><span class="prcie1">$62.00</span><del class="prcie2">$45.00</del></div>
                            <div class="favoriteBtns">
                                <div class="favoriteBtn1">加入购物车</div>
                                <div data-id="1" class="favoriteBtn2">取消收藏</div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="wareInfo">
                    <div class="wareImage">
                        <img src="../image/testsp.png" />
                    </div>
                    <div class="wareData">
                        <div class="wareName">广西车厘子</div>
                        <div class="wareGuiGe">2kg</div>
                        <div class="warePrice">
                            <div><span class="prcie1">$62.00</span><del class="prcie2">$45.00</del></div>
                            <div class="favoriteBtns">
                                <div class="favoriteBtn1">加入购物车</div>
                                <div class="favoriteBtn2">取消收藏</div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="shop_Info">
                    <div class="shopImage">
                        <img src="../image/testsp.png" />
                    </div>
                    <div class="shopData">
                        <div class="shopName">
                            <div>hengDu.黑店</div>
                            <div class="favoritedelete">取消收藏</div>
                        </div>
                        <div class="shop_sign">欢迎光临本店，本店新开张，诚信经营，只赚信誉不赚钱，谢谢。</div>                        
                    </div>
                </li>

                <li class="com_Info">
                    <div class="comImage">
                        <img src="../image/testsp.png" />
                    </div>
                    <div class="conData">
                        <div class="shopName">
                            超新鲜蔬菜、水果，吃了健康养生
                        </div>
                        <div class="comUser coms">
                            <div class="userBox1">
                                <img class="userTx" src="../image/tx.png" />
                                <div class="name">王多多王多多</div>
                            </div>
                            <div class="comCount">
                                <i></i>2508
                            </div>

                        </div>
                        <div class="BoxRight">
                            <div class="favoritedelete">取消收藏</div>
                        </div>
                    </div>
                </li> 
                -->
        </ul>
        
        <div class="pageHide dn">暂无数据..</div>
    </section>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
	 function delItem(id){
        event.stopPropagation();
        pop.loading();
        getAjax(Interface.del_collect,{token:token,id:id},function(res){
            pop.close();
            pop.notice(res.msg);
            deleteElement($("#ware_"+id),1);
            api.sendEvent({
                name: 'duihuanyhq',
                extra: {}
            });
        },function(res,err){})
    }
    var page =1;
    var type =1;
    var ifpage = true;
    apiready = function(){
        $api.fixStatusBar($api.dom('header'));
        api.setStatusBarStyle({
            color: '#fff',//设置APP状态栏背景色
            style: 'dark'
        });
        api.addEventListener({
            name: 'scrolltobottom',
            extra: {
                 threshold: 10
            }
         }, function(ret, err) {
             //页码+1，继续请求数据
             
             if(ifpage){
                page++;
                ready();
             }
             
        });
        ifCnAndEn();
        ready();
    };
    function ready(){
        getAjax(Interface.member_collect,{token:token,page:page,type:type},function(res){
            console.log(JSON.stringify(res));
            var list = res.data;
            if(page==1){
                $(".favoritePageList").empty();
            }
            if(list){
                
                $(".pageHide").addClass("dn");ifpage=true;
                $.each(list,function(i,item){
                    var html ='';
                    var name = '';
                    var jr = '加入购物车';
                    var qx = '取消收藏';
                    if(cnen==1){
                        name = item.title;
                    }else{
                        name = item.egname;
                        qx='Cancel';
                        jr='Add Cart'
                    }
                    if(type==1){
                        var name = '';
                        var jr = '加入购物车';
                        var qx = '取消收藏';
                        if(cnen==1){
                            name = item.title;
                        }else{
                            name = item.egname;
                            qx='Cancel';
                            jr='Add Cart'
                        }
                        html += '<li onclick="goWare(\''+item.id+'\')" id="ware_'+item.cid+'"  class="wareInfo">';
                            html +='<div class="wareImage">';
                                html +='<img src="'+getImg(item.icon)+'" />';
                            html +='</div>';
                            html +='<div class="wareData">';
                                html +='<div class="wareName">'+name+'</div>';
                                //html +='<div class="wareGuiGe">2kg</div>';
                                html +='<div class="warePrice">';
                                    html +='<div>';
                                    if(item.old_price == ""){
                                        html+='<span class="prcie1">$'+item.new_price+'</span>';
                                    }else{
                                        html+='<span class="prcie1">$'+item.new_price+'</span>';
                                        html+='<del class="prcie2">'+item.old_price+'</del>';
                                    }
                                    html +='</div><div class="favoriteBtns">';
                                        html +='<div onclick="goWare('+item.id+')" class="favoriteBtn1">'+jr+'</div>';
                                        html +='<div onclick="delItem('+item.cid+')"  class="favoriteBtn2">'+qx+'</div>';
                                    html +='</div>';
                                html +='</div>';
                            html +='</div>';
                        html +='</li>';
                    }else if(type==2){
                        if(cnen==2){
                            item.username =item.egusername;
                        }
                        html +='<li onclick="goClass(\''+item.uid+'\','+i+')" id="ware_'+item.cid+'"  class="shop_Info">';
                            html +='<div class="shopImage">';
                                html +='<img src="'+getImg(item.icon)+'" />';
                            html +='</div>';
                            html +='<div class="shopData">';
                                html +='<div class="shopName">';
                                    html +='<div>'+item.username+'</div>';
                                    html +='<div onclick="delItem('+item.cid+')" class="favoritedelete">'+qx+'</div>';
                                html +='</div>';
                                html +='<div class="shop_sign">'+item.description+'</div>';                        
                            html +='</div>';
                        html +='</li>';
                    }else{
                        if(cnen==2){
                            item.title =item.egname;
                        }
                        html +='<li onclick="go_details(\''+item.comm_id+'\')" id="ware_'+item.id+'" class="com_Info">';
                            html +='<div class="comImage">';
                                html +='<img src="'+getImg(item.icon)+'" />';
                            html +='</div>';
                            html +='<div class="conData">';
                                html +='<div class="shopName">'+item.title+'</div>';
                                html +='<div class="comUser coms">';
                                    html +='<div class="userBox1">';
                                        html +='<img class="userTx" src="'+getImg(item.uicon)+'" />';
                                        html +='<div class="name">'+item.username+'</div>';
                                    html +='</div>';
                                    html +='<div class="comCount"> <i></i>'+item.view_num+'</div>';
                                html +='</div>';
                                html +='<div class="BoxRight">';
                                    html +='<div onclick="delItem('+item.id+')" class="favoritedelete">'+qx+'</div>';
                                html +='</div>';
                            html +='</div>';
                        html +='</li>';
                    }
                    $(".favoritePageList").append(html);
                })
                if(list.length<10){
                    $(".getPage").hide();
                }
            }else{
                 ifpage=false;
                 if(page==1){$(".pageHide").removeClass("dn");}
            }
        },function(res,err){})
    }
    $(".orderClass li").click(function(){
        $(".orderClass li").removeClass("on");
        $(this).addClass("on");
        type = Number($(this).index())+1;
        page =1;
        ready();
    })

    function goClass(id,i){
        var p ={
            sdid:id
        }
        openWin('shop','shop.html',p);
    }
    function go_details(id){
        openWin('community_details','community_details.html',{id:id});
    }
</script>
<script type="text/javascript">
    function ifCnAndEn(){
        if(cnen==2){
            $(".pageTitle").eq(0).html('My Wish List');
            $(".orderClass li").eq(0).html('Ware<i></i>');
            $(".orderClass li").eq(1).html('Shop<i></i>');
            $(".orderClass li").eq(2).html('Community<i></i>');
             $(".pageHide").html('Not data');
            
        }
    }
</script>
</html>